The technique of separating text and figures from a document image is very useful, and may be used for document layout analysis, document image layer compression, etc. Existing commercial products include a document image compression technique, it is capable of, for example under a condition of 300 DPI sampling in color mode, compressing a typical magazine page into 40-60 KB, which is about 5-10 times of the compression ratio of JPEG, while maintaining a subjectively similar image quality. The first stage of a typically existing image compression technique is separating foreground (text) from background (figures and document background) by the two dimensional Hidden Markov Model. It usually causes over-segmentation at the initial stage of separating the foreground, so some different filters are applied to delete most of the apparent errors.